package com.zhipu.balance.pop

import android.widget.Button
import android.widget.EditText
import com.blankj.utilcode.util.ActivityUtils
import com.blankj.utilcode.util.KeyboardUtils
import com.blankj.utilcode.util.SPUtils
import com.blankj.utilcode.util.ToastUtils
import com.lxj.xpopup.core.CenterPopupView
import com.zhipu.balance.R

/**
 * 内网设置
 */
class IntranetSettingsPopup :  CenterPopupView(ActivityUtils.getTopActivity()){

    override fun getImplLayoutId(): Int {
        return R.layout.popup_intranet_settings
    }


    override fun onCreate() {
        super.onCreate()

        var mNetworkSettings = findViewById<EditText>(R.id.NetworkSettings)
        var networkSettings = SPUtils.getInstance().getString("NetworkSettings","")
        mNetworkSettings.setText(networkSettings)
        /**
         * 取消
         */
        findViewById<Button>(R.id.Cancel).setOnClickListener {
            //隐藏软键盘
            KeyboardUtils.hideSoftInput(mNetworkSettings)
            dismiss()
        }

        /**
         * 确认添加
         */
        findViewById<Button>(R.id.ConfirmAdd).setOnClickListener {

            val addressNetworkSettings = mNetworkSettings.text.toString()
            SPUtils.getInstance().put("NetworkSettings", addressNetworkSettings)
            ToastUtils.make().show("修改成功可以上传了")
            //隐藏软键盘
            KeyboardUtils.hideSoftInput(mNetworkSettings)
            dismiss()
        }

    }
}